<!DOCTYPE html>
<html lang="en">
    <head>
        <meta charset="UTF-8">
        <meta name="viewport" content="width=device-width, initial-scale=1" />
        <title>业务员业绩统计</title>
        <% include("/common/common_css_js.html"){} %>
    </head>
    <body>
        <div style="padding-bottom: 5px;">
            <div id="queryForm" class="uc-toolbaroverflow" _borderStyle="border-top:0;">
                <span>业务员:</span>
                <div id="keyDeliveryCustomerSalemanId" name="keyDeliveryCustomerSalemanId" class="mini-autocomplete" style="width:150px;"  popupWidth="500" textField="name" valueField="id"
                     required="false" requiredErrorText="业务员不能为空"
                     url="${base}/pages/customer_manage/queryDeliveryCustomerSalesmanByKey"
                     searchField="key"
                     emptyText="业务员姓名或电话">
                    <div property="columns">
                        <div header="姓名" field="name" width="150"></div>
                        <div header="电话" field="mobile" width="150"></div>
                    </div>
                </div>

                <span class="separator"></span>
                <span>开单日期：</span>
                <input id="keyOpenBillStartDate" name="keyOpenBillStartDate"  class="mini-datepicker"   format="yyyy-MM-dd"/>--<input id="keyOpenBillEndDate" name="keyOpenBillEndDate" class="mini-datepicker"  format="yyyy-MM-dd"/>

                <span class="separator"></span>
                <span>结算状态:</span>
                <input id="keySettlementStatusId" name="keySettlementStatusId" class="mini-combobox" style="width:120px;" textField="name" valueField="id" emptyText="请选择..."
                       required="false" allowInput="false" showNullItem="true" nullItemText="请选择..." requiredErrorText="没有选择结算状态"/>

                <div style="margin-top: 5px"></div>
                <% if(so.hasPermission("salesman:query")){%>
                    <a class="mini-button" iconCls="icon-search" onclick="searchBill()">查询</a>
                <% } %>

                <% if(so.hasPermission("salesman:queryCndClear")){%>
                    <a class="mini-button" iconCls="icon-new" onclick="clearSearch()">清空查询条件</a>
                <% } %>

                <span class="separator"></span>
                <% if(so.hasPermission("salesman:download")){%>
                    <#download_grid id="downloadGrid" theGridId="datagrid1" theFileName="业务员业绩统计表"/>
                <% } %>

            </div>
        </div>

        <div class = "mini-fit">
            <div id="datagrid1" class="mini-datagrid"
                 style="width: 100%; height: 100%;"
                 url="${base}/pages/finance_manage/statistics/querySalesmanStatisticsList" idField="id"
                 showPager="true" pageSize="20" sizeList="[10,20,30,50,100]"
                 multiSelect = "true" allowResize="true"
                 showGroupsSummary="true" showSummaryRow="true" summaryPosition="bottom"
                 allowSortColumn = "true"
                 ondrawsummarycell="summaryRight"
            >
                <div property="columns">
                    <div field="deliveryCustomerSalemanId" width="140" headerAlign="center" align="center" allowSort="true" data-options='{cacheName:"sysUser"}' renderer="commonRender">发货客户业务员</div>
                    <div field="openBillMonth" width="140" headerAlign="center" align="center" allowSort="false" >开单月份</div>
                    <div field="totalBill" width="140" headerAlign="center" align="right" allowSort="false" summaryType="sum">单数合计</div>
                    <div field="totalNumber" width="140" headerAlign="center" align="right" allowSort="false" summaryType="sum">件数合计</div>
                    <div field="totalActualWeight" width="140" headerAlign="center" align="right" allowSort="false" renderer="public_moneyRenderer" summaryType="sum">实重合计</div>
                    <div field="totalChargeableWeight" width="140" headerAlign="center" align="right" allowSort="false" renderer="public_moneyRenderer" summaryType="sum">计重合计</div>
                    <div field="totalVolume" width="140" headerAlign="center" align="right" allowSort="false" renderer="public_moneyRenderer" summaryType="sum">体积合计</div>
                    <div field="totalTransportCost" width="140" headerAlign="center" align="right" allowSort="false" renderer="public_moneyRenderer" summaryType="sum">运费合计</div>

                    <div field="totalServiceCharge" width="140" headerAlign="center" align="right" allowSort="false" renderer="public_moneyRenderer" summaryType="sum">业务费合计</div>
                    <div field="totalShareCost" width="140" headerAlign="center" align="right" allowSort="false" renderer="public_moneyRenderer" summaryType="sum">分摊成本合计</div>
                    <div field="totalGrossProfit" width="140" headerAlign="center" align="right" allowSort="false" renderer="public_moneyRenderer" summaryType="sum">利润合计</div>

                    <div field="totalSettlementAmount" width="140" headerAlign="center" align="right" allowSort="false" renderer="public_moneyRenderer" summaryType="sum">结算金额合计</div>


<!--                    <div field="totalInsuranceFee" width="140" headerAlign="center" align="right" allowSort="false" renderer="public_moneyRenderer" summaryType="sum">保费合计</div>-->
<!--                    <div field="totalOpenBillDeliveryCharge" width="140" headerAlign="center" align="right" allowSort="false" renderer="public_moneyRenderer" summaryType="sum">开单送货费合计</div>-->
<!--                    <div field="totalAgentDeliveryCharge" width="140" headerAlign="center" align="right" allowSort="false" renderer="public_moneyRenderer" summaryType="sum">代理送货费合计</div>-->
<!--                    <div field="totalTax" width="140" headerAlign="center" align="right" allowSort="false" renderer="public_moneyRenderer" summaryType="sum">总税金</div>-->

<!--                    <div field="totalFuelSurcharge" width="140" headerAlign="center" align="right" allowSort="false" renderer="public_moneyRenderer" summaryType="sum">总燃油费</div>-->
<!--                    <div field="totalCollectionMoney" width="140" headerAlign="center" align="right" allowSort="false" renderer="public_moneyRenderer" summaryType="sum">代收款合计</div>-->
<!--                    <div field="totalOtherCharges" width="140" headerAlign="center" align="right" allowSort="false" renderer="public_moneyRenderer" summaryType="sum">其他费用合计</div>-->


<!--                    <div field="totalActualTransportCost" width="140" headerAlign="center" align="right" allowSort="false" renderer="public_moneyRenderer" summaryType="sum">总实收运费</div>-->
<!--                    <div field="totalDeliveryCustomerPaymentAmount" width="140" headerAlign="center" align="right" allowSort="false" renderer="public_moneyRenderer" summaryType="sum">发货客户付款合计</div>-->
<!--                    <div field="totalReceiveCustomerPaymentAmount" width="140" headerAlign="center" align="right" allowSort="false" renderer="public_moneyRenderer" summaryType="sum">收货客户付款合计</div>-->
<!--                    <div field="totalAmount" width="140" headerAlign="center" align="right" allowSort="false" renderer="public_moneyRenderer" summaryType="sum">总金额合计</div>-->

<!--                    <div field="totalActualAmount" width="140" headerAlign="center" align="right" allowSort="false" renderer="public_moneyRenderer" summaryType="sum">实收金额合计</div>-->
<!--                    <div field="totalOperatingCost" width="140" headerAlign="center" align="right" allowSort="false" renderer="public_moneyRenderer" summaryType="sum">操作费合计</div>-->

                </div>
            </div>
        </div>

        <script type="text/javascript">
            mini.parse();

            let keyDeliveryCustomerSalemanId = mini.get("keyDeliveryCustomerSalemanId");
            let keyOpenBillStartDate = mini.get("keyOpenBillStartDate");
            let keyOpenBillEndDate = mini.get("keyOpenBillEndDate");

            let keySettlementStatusId = mini.get("keySettlementStatusId");


            let grid = mini.get("datagrid1");

            $(function () {
                // 结算状态
                let keySettlementStatusIdJsonDate  = commonRenderSysDicDropListByKey("sysDic","XT_DIC_SETTLEMENT_STATUS");
                keySettlementStatusId.load(keySettlementStatusIdJsonDate);

                // 加载列表数据
                grid.load();
            });

            /**
             * 清空查询条件
             */
            function clearSearch(){
                let form = new mini.Form("#queryForm");
                form.clear();
            }

            /**
             * 根据查询条件查询分单
             */
            function searchBill(){
                let form = new mini.Form("#queryForm");
                let data = form.getData(true);
                grid.load(data);
            }

            /**
             * 设置底部统计样式
             * @param e
             */
            function summaryRight(e){
                e.cellStyle="text-align:right;color:red;font-size:18px;font-weight:bold";
            }
        </script>
    </body>
</html>